package com.le.tester.book.concurrentchallenge.aviodDanger;

/**
 * createTime：2025-04-21 14:11
 * description：顺序死锁，不要这么做
 */
public class LeftRightDeadLock {

    private final Object left = new Object();
    private final Object right = new Object();

    public void leftRight() {
        synchronized (left) {
            synchronized (right) {
                System.out.println("doSomeThing");
            }
        }
    }

    public void rightLeft() {
        synchronized (right) {
            synchronized (left) {
                System.out.println("doSomeThing");
            }
        }
    }
}
